#!/usr/bin/python
import urllib2
import httplib

url = "www.cnn.com"
conn = httplib.HTTPConnection(url)
#I don't know why we provide a path here.. but it's an empty file.
conn.putrequest("GET", "/home/praveen/headers.txt")
#Set the user agent field of the header as mobile
conn.putheader("User-Agent","Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)")
conn.endheaders()
#Get Response
response = conn.getresponse()
headers = response.getheaders()
print headers
leng = len(response.read())
lgtInHeader = response.getheader('content-length')
if lgtInHeader == None:
  print "\nNo content length"
else:
  print lgtInHeader
  
print "\nLength :"+str(leng)


